package com.jf.cloud.payment.allinpay.util;


import com.alibaba.fastjson.JSON;
import com.jf.cloud.payment.allinpay.member.req.*;
import com.jf.cloud.payment.allinpay.member.resp.*;

import java.util.List;

/**
 * @author LGH
 */
public class AllinpayMemberService {

	/**
	 * @param cm 创建会员
	 * @return
	 */
	public static CreateMemResp createMember(CreateMember cm){
		return AllinpayUtil.sendData(cm, CreateMemResp.class);
	}

	/**
	 * @param svc 绑定手机号 - 发送短信验证码
	 * @return
	 */
	public static PhoneVerificationResp sendVerificationCode(SendVerificationCode svc){
		return AllinpayUtil.sendData(svc, PhoneVerificationResp.class);
	}


	/**
	 * @param bindPhone 绑定手机
	 * @return
	 */
	public static PhoneVerificationResp bindPhone(BindPhone bindPhone){
		return AllinpayUtil.sendData(bindPhone, PhoneVerificationResp.class);
	}

	/**
	 * @param setRealName 个人实名认证
	 * @return
	 */
	public static SetRealNameResp setRealName(SetRealName setRealName){
		return AllinpayUtil.sendData(setRealName, SetRealNameResp.class);
	}

	/**
	 * @param setCompanyInfo 设置企业信息
	 * @return
	 */
	public static BizUserId setCompanyInfo(SetCompanyInfo setCompanyInfo){
		return AllinpayUtil.sendData(setCompanyInfo, BizUserId.class);
	}


	/**
	 * 获取个人用户信息
	 * @return
	 */
	public static UserInfo getUserInfo(GetMemberInfo getMemberInfo){
		MemberInfo memberInfo = AllinpayUtil.sendData(getMemberInfo, MemberInfo.class);
		return JSON.parseObject(memberInfo.getMemberInfo(), UserInfo.class);
	}

	/**
	 * 获取企业用户信息
	 */
	public static CompanyInfo getCompanyInfo(GetMemberInfo getMemberInfo){
		MemberInfo memberInfo = AllinpayUtil.sendData(getMemberInfo, MemberInfo.class);
		return JSON.parseObject(memberInfo.getMemberInfo(), CompanyInfo.class);
	}

	/**
	 * 查询卡bin
	 */
	public static CardBinInfo getBankCardBin(GetBankCardBin getBankCardBin){
		BankCardBin bankCardBin = AllinpayUtil.sendData(getBankCardBin, BankCardBin.class);
		return JSON.parseObject(bankCardBin.getCardBinInfo(), CardBinInfo.class);
	}

	/**
	 * 绑定银行卡
	 */
	public static ApplyBindBankCardResp applyBindBankCard(ApplyBindBankCard applyBindBankCard){
		return AllinpayUtil.sendData(applyBindBankCard, ApplyBindBankCardResp.class);
	}

	/**
	 * 确认绑定银行卡
	 */
	public static BindBankCardResp bindBankCard(BindBankCard bindBankCard){
		return AllinpayUtil.sendData(bindBankCard, BindBankCardResp.class);
	}


	/**
	 * 获取用户所绑定的银行卡
	 */
	public static List<BindCard> queryBankCard(QueryBankCard queryBankCard){
		return AllinpayUtil.sendDataGetArray(queryBankCard, BindCard.class);
	}

	/**
	 * 解除绑定银行卡
	 */
	public static CardNoWithUid unbindBankCard(UnbindBankCard unbindBankCard){
		return AllinpayUtil.sendData(unbindBankCard, CardNoWithUid.class);
	}

	/**
	 * 锁定会员
	 */
	public static BizUserId lockMember(LockMember lockMember){
		return AllinpayUtil.sendData(lockMember, BizUserId.class);
	}

	/**
	 * 解锁会员
	 */
	public static BizUserId unlockMember(UnlockMember unlockMember){
		return AllinpayUtil.sendData(unlockMember, BizUserId.class);
	}


}
